<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    * {
        margin: 0;
        padding: 0;
        list-style: none;
        text-decoration: none;
    }

    body {
        background-color: #cdcdcd;
    }

    header {
        height: 50px;
        background-color: rgba(47, 47, 47, 0.98);
    }

    section {
        width: 600px;
        margin: 0 auto;
    }

    header section {
        display: flex;
        justify-content: space-between;
        align-items: center;

    }

    header section p {
        line-height: 50px;
        color: #DDD;
        font-size: 24px;
        cursor: pointer;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    }

    header section input {
        width: 60%;
        height: 26px;
        text-indent: 10px;
        border-radius: 5px;
        box-shadow: 0 1px 0 rgb(255 255 255 / 24%), 0 1px 6px rgb(0 0 0 / 45%) inset;
        border: none;
    }

    main {
        width: 600px;
        margin: 0 auto;
    }

    .title {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin: 30px 0;
    }

    .title span {
        padding: 0 5px;
        height: 20px;
        border-radius: 20px;
        background: #E6E6FA;
        /* line-height: 22px; */
        text-align: center;
        color: #666;
        font-size: 14px;
    }

    .list li a {
        width: 14px;
        height: 12px;
        border-radius: 14px;
        border: 6px double #FFF;
        background: #CCC;
        line-height: 14px;
        text-align: center;
        color: #FFF;
        font-weight: bold;
        font-size: 14px;
        cursor: pointer;
        margin-right: 10px;
    }

    .list li {
        display: flex;
        align-items: center;
        height: 32px;
        background-color: #fff;
        border-radius: 3px;
        border-left: 5px solid #629A9C;
        box-shadow: 0 1px 2px rgb(0 0 0 / 7%);
        margin-bottom: 10px;
        position: relative;

    }

    .list li p {
        flex: 1;
    }

    .list li input {
        width: 22px;
        height: 22px;
        margin: 0 15px;
    }

    .list li button {
        position: absolute;
        right: 30px;
        top: 15%;
        width: 50px;
        background-color: skyblue;
        border: 3px solid #629A9C;
        border-radius: 20px;
    }

</style>
<body>
    <div id="app">
        <header>
            <section>
                <p>ToDoList</p>
                <input type="text" v-model="inpval" @keyup.enter="tianjia">
            </section>
        </header>
        <main>
            <!-- 正在执行的事情 -->
            <section class="dolist">
                <div class="title">
                    <h2>正在进行</h2>
                </div>
    
                <ul class="list">
                    <li v-for="(item,index) in texts"  v-show="item.zhuangtai"><input type="checkbox" @click="gaibian(index)" v-model="item.aaa">{{item.text}} <button @click="shanchu(index)">删除</button></li>
                </ul>
            </section>
    
            <!-- 以完成的事情 -->
            <section class="downlist">
                <div class="title">
                    <h2>以完成</h2>
                </div>
    
                <ul class="list">
                    <li v-for="(item,index) in texts" v-show="item.flag"><input type="checkbox" @click="huiqu(index)" v-model="item.aaa">{{item.text}} <button @click="shanchu(index)">删除</button></li>
                </ul>
            </section>
        </main>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        let pc = new Vue({
            el:"#app",
            data:{
                inpval:"",
                texts:[],
            },
            methods:{
                tianjia(){
                    let obj = {}
                    obj.text=this.inpval
                    obj.flag = false
                    obj.zhuangtai = true
                    obj.aaa=false
                    this.texts.push(obj)
                    this.inpval=""
                },

                gaibian(index){
                    this.texts[index].flag = !this.texts[index].flag
                    this.texts[index].zhuangtai = !this.texts[index].zhuangtai
                    this.texts[index].aaa = !this.texts[index].aaa

                },
                huiqu(index){
                    this.texts[index].flag = !this.texts[index].flag
                    this.texts[index].zhuangtai = !this.texts[index].zhuangtai
                    this.texts[index].aaa = !this.texts[index].aaa
                },
                shanchu(index){
                    this.texts.splice(index,1)
                }
            }
        })
    </script>
</body>
</html>